<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/commons/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title>功能列表</title>
  </head>
  <body>
 	<a class="btn-link pull-right" href="${ctx}/admin/permission/form">添加</a>
 	<div class="col-md-3">
	  <ul id="permisstionTree" class="ztree"></ul>
  </div>
  <div class="col-md-9 form-horizontal">
  		<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">父级：</label>
		    <div class="col-md-10">
		      <input name="pid"  class="form-control" type="hidden"  id="pid" value="${bean.pid}"/>
		      <input readonly="readonly" class="form-control" id="pName" value="${bean.permi.name }"/>
		    </div>
	  	</div>
 		<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">功能名：</label>
		    <div class="col-md-10">
		    <input type="hidden" value="${bean.id}" name="id"/>
		      <input name="name" class="form-control" value="${bean.name}" readonly="readonly"
		       datatype="s2-12" placeholder="请输入角色名"/>
		    </div>
	  	</div>
 		<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">code：</label>
		    <div class="col-md-10">
		      <input name="code" class="form-control" value="${bean.code}" readonly="readonly"
		       datatype="s3-12" placeholder="请输入code"/>
		    </div>
	  	</div>
	  	<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">描述：</label>
		    <div class="col-md-10">
		      <input name="description" class="form-control" value="${bean.description}" readonly="readonly"
		       placeholder="请输入描述"/>
		    </div>
	  	</div>
	  	<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">类型：</label>
		    <div class="col-md-10">
		     <input name="type" class="form-control" value="${bean.type}" readonly="readonly"
		       placeholder="请输入描述"/>
		    </div>
	  	</div>
	  	<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">访问地址：</label>
		    <div class="col-md-10">
		      <input name="url" class="form-control" value="${bean.url}" readonly="readonly"
		       placeholder="请输入访问地址"/>
		    </div>
	  	</div>
	  	<div class="form-group">
	   	<div class="col-md-5 text-right">
		   	<a class="btn btn-primary" id="updataBtn" href="#">修改</a>
	  	</div>
	  </div>
  </div>
  <link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/demo.css" type="text/css"/>
  <link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
  <script type="text/javascript" src="${ctx}/static/js/zTree_v3/js/jquery.ztree.all-3.5.min.js"></script>
   	<script type="text/javascript">
   	var setting = {
   		   	view:{selectedMulti:false},
   		 callback:{
   		   	onClick:function(event,treeId,treeNode){
   	   		   	if(treeNode.id!='${bean.id}'){
		   	   		   	$("input[name='pid']").val(treeNode.pid);
			   	   		$("input[name='name']").val(treeNode.name);
				   	   	$("input[name='code']").val(treeNode.code);
					   	$("input[name='description']").val(treeNode.description);
					   	$("input[name='type']").val(treeNode.type);
					   	$("input[name='url']").val(treeNode.url);
					   	var pNode = treeNode.getParentNode();
					   	if(pNode){
						   	$("#pName").val(pNode.name);
						   	}else{
						   		$("#pName").val("");
							   	}
					   	$("#updataBtn").attr("href","${ctx}/admin/permission/form?id="+treeNode.id);
   	   	   		   	}
   	   		   	}
      	   		 },
			data: {
				simpleData: {
   					pIdKey:"pid",
					enable: true
				},
				key:{url:'xhref'}
			}
		};
	function stickied(){
		$("#pName").val("");
  		$("#pid").val("");
	}
 	$(function(){
 	 var permTree=$.fn.zTree.init($("#permisstionTree"), setting,eval('${permissionTree}'));
 	 permTree.expandAll(true);
		$("#form").Validform({
			tiptype:4
			})
		});
	</script>
  </body>
</html>
